package 计数法.检查所有出现字符次数是否相同;

import java.util.Arrays;

/**
 * TODO
 *
 * @className: jcsycxzfcssfxt
 * @description: TODO
 * @author: 等什么柠檬君
 * @date: 2022-05-04 17:52
 **/
public class jcsycxzfcssfxt {
    public static void main(String[] args) {
        int[] arr = new int[26];
        String a = "vvvvvvvvvvvvvvvvvvv";

        System.out.println(areOccurrencesEqual(a));
    }

    public static boolean areOccurrencesEqual(String s) {

        int[] arr = new int[26];
        for(int i = 0;i < s.length(); ++i){
            ++arr[(int)s.charAt(i)-97];
        }
        System.out.println(Arrays.toString(arr));
        System.out.println("sum "+Arrays.stream(arr).sum());
        System.out.println("length "+s.length());
        int count = 0;
        for(int i = 0;i < 26; ++i){
            if (arr[i] > 0) {
                if (count == 0) {
                    count = arr[i];
                } else if (count != arr[i]) {
                    return false;
                }
            }

//            if (arr[(int)s.charAt(i)-97]!=0){
//                if (arr[(int)s.charAt(i)-97] == count){
//                    continue;
//                }else {
//                    return false;
//                }
//            }
        }


        return true;
    }
}
